package com.cxhc.demo1005;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    ViewPager vp;

    MyAdapter adapter;

    List<Fragment> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        vp = findViewById(R.id.vp);

        Fragment fragment = new Aframgent();
        list.add(fragment);
        fragment = new Bframgent();
        list.add(fragment);
        fragment = new Cframgent();
        list.add(fragment);
        vp.setAdapter(adapter = new MyAdapter(getSupportFragmentManager(),list));
    }
}
